import { http } from './request'

type Menu = {
    id: number
    name: string
    url: string
}

export const menuApi = {
    // 获取菜单列表
    fetchMenus: () => http.get<Menu[]>('/menus'),

    // 创建菜单
    createMenu: (menu: Omit<Menu, 'id'>) =>
        http.post<Menu>('/menus', menu),

    // 更新菜单
    updateMenu: (id: number, menu: Omit<Menu, 'id'>) =>
        http.put<null>(`/menus/${id}`, menu),

    // 删除菜单
    deleteMenu: (id: number) =>
        http.delete<null>(`/menus/${id}`)
}